import { useNavigate } from 'react-router-dom';
import store from "../../store/index.js";
import http from '../../server/http.js'
import {useEffect, useState} from "react";
import { UserOutlined } from '@ant-design/icons';
import { Avatar, Space,Button } from 'antd';
const Home = () => {
    const navigate = useNavigate();
    const [httpData,setHttpData] = useState('')

    useEffect(()=>{
        http.post({
            url:'/api/captchas/index'
        }).then((res)=>{
            setHttpData(res.data)
        })
    },[])



    function goPage(path){
        return ()=>navigate(path)
    }
    return (<div>

        <Button type="primary">
            获取store中的数据{  store.getState().count  }
        </Button>
        <Space wrap size={16}>
            <Avatar size={64} icon={<UserOutlined />}/>

            <Avatar size="large" icon={<UserOutlined />}  />
        </Space>

        <div>
            http中获取到的数据{httpData.data?.captcha}

            <img src={httpData.data?.captcha} alt=""/>
            
        </div>


        <button onClick={goPage('/list')}>
            跳转到list
        </button>
        <button onClick={goPage('/news/time')}>
            跳转到time
        </button>
    </div>)
};

export default Home;
